package com.moyou.weichat;

import android.os.Build;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;

import com.alibaba.fastjson.JSONObject;
import com.hyphenate.chat.EMClient;
import com.moyou.weichat.chat.ChatManger;
import com.moyou.weichat.utils.ConstantUtils;
import com.moyou.weichat.utils.PreferenceHelper;

public class SplashActivity extends BaseActivity {

    @Override
    protected int getLayout() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initTitle() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        ChatManger.getChatManger().loadChatDate(); //在闪屏也进行加载数据
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initEventAndData() {
        if (PreferenceHelper.getBoolean(ConstantUtils.IS_LOGIN, false)) {
            theadrStartAct(MainActivity.class);
        } else {
            theadrStartAct(LoginActivity.class);
        }
    }

    //延时跳转是否需要登录的判断
    public void theadrStartAct(final Class cla) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                startAct(cla);
                finish();
            }
        }, 2000);
    }

    @Override
    protected boolean toggleOverridePendingTransition() {
        return false;
    }

    @Override
    protected TransitionMode getOverridePendingTransitionMode() {
        return TransitionMode.LEFT;
    }

    @Override
    protected void createPresenter() {

    }

}